package org.springframework.ai.chat.client.advisor;

import java.util.function.Predicate;

import org.springframework.ai.chat.client.ChatClientResponse;
import org.springframework.ai.chat.model.ChatResponse;

/**
 * @author xuguan
 * @since 2025/9/28
 */
public final class AdvisorUtils {

	private AdvisorUtils() {
	}

	public static Predicate<ChatClientResponse> onFinishReason() {
		return (chatClientResponse) -> {
			ChatResponse chatResponse = chatClientResponse.chatResponse();
			return chatResponse != null && chatResponse.getResults() != null
					&& chatResponse.getResults()
						.stream()
						.anyMatch((result) -> result != null && result.getMetadata() != null);
		};
	}

}
